package cn.stronglink.asset.message.mq.dam.entity;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

import cn.stronglink.asset.message.mq.dam.message.MQMessageOfDAM;

public class ScreenRequertMessageFactory {
	public static List<MQMessageOfDAM> parse(MQMessageOfDAM msg){
		List<MQMessageOfDAM> list = new ArrayList<>();
		ScreenCommandEntity sc = ((JSONObject)msg.getAwsPostdata()).toJavaObject(ScreenCommandEntity.class);
		String[] commands = sc.getCommand().split("FFFCFFFF");
		for(int i=0;i<commands.length;i++) {
			MQMessageOfDAM newMsg = new MQMessageOfDAM();
			newMsg.setActioncode(msg.getActioncode());
			newMsg.setDevType(msg.getDevType());
			newMsg.setTimestamp(System.currentTimeMillis());
			
			ScreenCommandEntity newSc = new ScreenCommandEntity();
			newSc.setCommand(commands[i]);
			newSc.setRackConverCode(sc.getRackConverCode());
			newMsg.setAwsPostdata(newSc);
			list.add(newMsg);
		}
		
		return list;
	}
}
